package com.code.springbootmybatis.service.impl;

import com.code.springbootmybatis.mapper.UserMapper;
import com.code.springbootmybatis.model.User;
import com.code.springbootmybatis.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author: liyufei
 * @date: 2018-04-30 1:32
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public User getByUsername(String username) {
        return userMapper.getUserByUsername(username);
    }

    @Override
    public void insertUser(User user) {
        user.setDate(LocalDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME));
        userMapper.insertUser(user);
    }
}
